package com.hanxiaozhang.constant;

import com.hanxiaozhang.util.StringUtil;

/**
 * 〈一句话功能简述〉<br>
 * 〈Redis模式枚举〉
 *
 * @author hanxinghua
 * @create 2022/9/5
 * @since 1.0.0
 */
public enum RedisModelEnum {

    SINGLE("single", "单节点"),
    CLUSTER("cluster", "集群"),
    MASTER_SLAVE("masterSlave", "主从"),
    SENTINEL("sentinel", "哨兵");


    private String code;
    private String name;

    RedisModelEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 判断是否包含code
     *
     * @param code
     * @return
     */
    public static Boolean containsCode(String code) {
        if (StringUtil.isBlank(code)) {
            return false;
        }

        for (RedisModelEnum modelEnum : RedisModelEnum.values()) {
            if (modelEnum.code.equals(code)) {
                return true;
            }
        }
        return false;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

}
